home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Utils Divers 1 / Horo Shareware / Horo / Horo.rsrc / TEXT_1562_T2. Text I_O.txt < prev    next >
Text File  |  1996-03-01  |  5KB  |  19 lines

  1. Text Input/Output
  2.   TextCt-based editors automatically handle all operations expected of typical text editors:  file handling, editing, scrolling, printing, etc.  Many programmers never write a single line of code to support such editors since they use them to simply view, edit, or print existing text files.
  3.   Other programmers, however, have a need to "write" and "read" text to and from editors.  TextCt provides several commands to support such text I/O via files, strings, or blocks of text in memory.  See the "Commands" topic for a complete description of the commands discussed below.
  4.  
  5. Program I/O
  6. ΓÇó File-Based
  7.   The TextCt command OpnCTxt can be used to read text from a file into a new or existing editor, and SavCTxt can be used to save all or part of the text in an editor to a disk file.  These commands put into the programmer's hands the same functionality that is available to the user via the use of standard menu items.
  8. ΓÇó String-Based
  9.   The command LineCIO supports the passing of a string of text to and from a specified editor window.  Such text is transferred via the uString string and is automatically converted to and from your language's native string type (C-, Pascal-, or Fortran-type strings).  Due to TextCt's internal use of a Pascal string, the amount of text that can be transferred by each call to LineCIO is limited to 255 characters.  If you choose to make use of LineCIO to move text to and from editors, be sure to read "About Compilers" on the FaceWare Utilities disk which contains many useful tips on number-to-string interconversions.
  10. ΓÇó Block-Based
  11.   The command BlokCIO is similar to LineCIO except that it can be used to transfer text between any memory block and an editor.  This command has the advantage of not being limited to moving 255 characters, but the disadvantage of not making use of your language's built-in string-handling routines to prepare and process the transferred text.
  12.     Many of the text I/O commands that you will be working with are selection-based.  This means that, when using such commands, your program may need to know, or be able to reset, the status of the current text selection.  This capability is provided by two other commands:  GetCTxt and SelCTxt.  GetCTxt returns information about the text in the specified editor, and SelCTxt can be used to change the current text selection.
  13.  
  14. Interactive I/O
  15.   A common use for TextCt editors is to support the direct input of "commands" or other information by the user.  The above discussion outlined the various ways that text can be moved to and from an editor, but did not address the question of when to perform such I/O.
  16.   One answer is to simply accept commands or information from the user in response to the selection of a program menu item.  In this case the user would enter a command, or select a block of commands or other information in the editor, and then choose a special program menu item that causes your program to process the entered information.
  17.   Another option is to make use of TextCt's special support for the Command key.  This support is activated by setting the "Command" option in the "Keys Accepted" menu in the Control dialog.  With this option set, the editor will return control to your program with a message when a Command key combination is pressed that is not already implemented in menus:  uMsgType = ModuleMsg, uMsgID = 1550, uMsgItem = 1001, and uResult = ASCII value of key pressed.
  18.   If Command keys are supported, the "Editor Setup" dialog can also be used to make TextCt interpret the Enter key as Command-Enter, or the Return key as Command-Return.  This makes it possible, for example, to have a program read every line typed into an editor by setting up the editor to return control whenever the Return key is hit.  NOTE:  If you set up the Return key as Command-Return so that it returns control when pressed, then pressing Return will not insert a carriage return in the editor.  To ensure that the user sees a carriage return inserted, respond to the message returned by calling LineCIO with a = -2 so that a carriage return gets inserted.
  19.   A large part of the example program tcDemoXY is devoted to demonstrating interactive text I/O, so you should study this program before attempting to implement this feature in your own editors.  The program illustrates the use of GetCTxt to find out what text is selected, and LineCIO to either get a single line of unselected text, or multiple lines of selected text, in response to a user's pressing of the Command-Return key combination.